package checkers;

import java.awt.Point;

/**
 * Encapsulates all of the point data for each occupiable space. Each point
 * represents one vertex of its position. The position is also represented with
 * its equivalent row and col in a grid starting from the upper left.
 * 
 */
public enum Position {

	P01(0, 1, new Point(288, 177), new Point(355, 177), new Point(277, 195),
			new Point(349, 195)), P03(0, 3, new Point(419, 177), new Point(485,
			177), new Point(416, 195), new Point(484, 195)), P05(0, 5,
			new Point(550, 177), new Point(614, 177), new Point(553, 195),
			new Point(621, 195)), P07(0, 7, new Point(677, 177), new Point(743,
			177), new Point(688, 195), new Point(758, 195)),

	P10(1, 0, new Point(211, 195), new Point(278, 195), new Point(193, 217),
			new Point(265, 217)), P12(1, 2, new Point(347, 195), new Point(413,
			195), new Point(339, 217), new Point(409, 217)), P14(1, 4,
			new Point(484, 195), new Point(554, 195), new Point(484, 217),
			new Point(558, 217)), P16(1, 6, new Point(622, 195), new Point(688,
			195), new Point(630, 217), new Point(701, 217)),

	P21(2, 1, new Point(264, 217), new Point(338, 217), new Point(251, 239),
			new Point(329, 239)), P23(2, 3, new Point(411, 217), new Point(484,
			217), new Point(407, 239), new Point(485, 239)), P25(2, 5,
			new Point(558, 217), new Point(629, 217), new Point(564, 239),
			new Point(639, 239)), P27(2, 7, new Point(702, 217), new Point(775,
			217), new Point(717, 239), new Point(794, 239)),

	P30(3, 0, new Point(174, 239), new Point(251, 239), new Point(150, 268),
			new Point(232, 268)), P32(3, 2, new Point(330, 239), new Point(404,
			239), new Point(317, 268), new Point(399, 268)), P34(3, 4,
			new Point(483, 239), new Point(561, 239), new Point(483, 268),
			new Point(569, 268)), P36(3, 6, new Point(640, 239), new Point(715,
			239), new Point(651, 268), new Point(733, 268)),

	P41(4, 1, new Point(232, 268), new Point(316, 268), new Point(213, 300),
			new Point(302, 300)), P43(4, 3, new Point(398, 268), new Point(483,
			268), new Point(392, 300), new Point(483, 300)), P45(4, 5,
			new Point(568, 268), new Point(650, 268), new Point(575, 300),
			new Point(664, 300)), P47(4, 7, new Point(735, 268), new Point(816,
			268), new Point(755, 300), new Point(845, 300)),

	P50(5, 0, new Point(124, 299), new Point(212, 300), new Point(89, 338),
			new Point(189, 338)), P52(5, 2, new Point(303, 300), new Point(393,
			300), new Point(287, 338), new Point(384, 338)), P54(5, 4,
			new Point(484, 300), new Point(574, 300), new Point(484, 338),
			new Point(582, 338)), P56(5, 6, new Point(664, 300), new Point(753,
			300), new Point(680, 338), new Point(778, 338)),

	P61(6, 1, new Point(189, 338), new Point(287, 338), new Point(160, 383),
			new Point(267, 383)), P63(6, 3, new Point(385, 338), new Point(483,
			338), new Point(375, 383), new Point(482, 383)), P65(6, 5,
			new Point(583, 338), new Point(679, 338), new Point(591, 383),
			new Point(699, 383)), P67(6, 7, new Point(779, 338), new Point(876,
			338), new Point(808, 383), new Point(914, 383)),

	P70(7, 0, new Point(52, 383), new Point(160, 383), new Point(6, 437),
			new Point(126, 437)), P72(7, 2, new Point(267, 383), new Point(375,
			383), new Point(245, 437), new Point(362, 437)), P74(7, 4,
			new Point(482, 383), new Point(591, 383), new Point(482, 437),
			new Point(602, 437)), P76(7, 6, new Point(698, 383), new Point(806,
			383), new Point(719, 437), new Point(840, 437));

	public final int row;
	public final int col;
	public final Point topLeft;
	public final Point topRight;
	public final Point bottomLeft;
	public final Point bottomRight;

	/**
	 * Internal constructor for the position
	 * 
	 * @param row
	 * @param col
	 * @param topLeft
	 * @param topRight
	 * @param bottomLeft
	 * @param bottomRight
	 */
	private Position(int row, int col, Point topLeft, Point topRight,
			Point bottomLeft, Point bottomRight) {
		this.row = row;
		this.col = col;
		this.topLeft = topLeft;
		this.topRight = topRight;
		this.bottomLeft = bottomLeft;
		this.bottomRight = bottomRight;
	}

	/**
	 * Returns the midPoint of the plane of each space represented by the four
	 * points in the position
	 * <p>
	 * 
	 * @return The Point.
	 */
	public Point midPoint() {
		Point left;
		Point right;

		left = new Point((bottomLeft.x + topLeft.x) / 2,
				(bottomLeft.y + topLeft.y) / 2);
		right = new Point((bottomRight.x + topRight.x) / 2,
				(bottomRight.y + topRight.y) / 2);

		return new Point((left.x + right.x) / 2, (left.y + right.y) / 2);
	}
}
